package spark.network.strategy;

import spark.network.protocol.Response;
import spark.network.strategy.IProtocolHandleStrategy;
import spark.network.protocol.Base;
import spark.network.protocol.ClockSyncReq;
import spark.network.protocol.ClockSyncRes;
import spark.utility.OutWrapper;

import java.util.Collection;

public class ClockSyncReqStrategy implements IProtocolHandleStrategy<ClockSyncReq> {
	@Override
	public void handle(ClockSyncReq packet, OutWrapper<Response> acknowledgement, Collection<Base> responses) {
		ClockSyncRes clockSyncRes = new ClockSyncRes(packet);
		clockSyncRes.setLocalTime(System.currentTimeMillis());

		acknowledgement.value = clockSyncRes;
	}
}